<template>
	<view class="main">
		<view class="sys-lst v-box">
			<view class="sys-itemWarn poser" v-for="(item,index) in listRow" :key="index">
				{{item.name}}
				<view class="sysWarn-poser">
					<!-- <view class="big-yuan"><label></label></view> -->
					<u-switch v-model="item.flag" @change="change(item,index)"></u-switch>
				</view>
			</view>
			
			<!-- <view class="sys-itemWarn poser">
				通过微信接受订阅通知
				<view class="sysWarn-poser">
					<view class="big-yuan2"><label></label></view>
				</view>
			</view>
			
			<view class="sys-itemWarn poser">
				通过APP接收推荐通知
				<view class="sysWarn-poser">
					<view class="big-yuan2"><label></label></view>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
import Index from "@/common/index-model.js"
let index = new Index()
let that = null	
export default {
	data() {
		return {
			listRow:[]
		}
	},
	methods: {
		getListRow() {
			this.listRow = []
			index.getPublicUserMember({},'client/individual/find/notification','get',res=>{
				if(res.data.code == 200 && res.data.success){
					this.listRow = res.data.result
					if(this.listRow.length>0){
						for(let i=0;i<this.listRow.length;i++){
							this.listRow[i].flag = this.listRow[i].status==0?false:true
						}
					}
				}else{
					this.listRow = []
				}
			})
		},
		change(item,index) {
			let send = {
				"code":item.code,
				"status":item.status==1?0:1
			}
			this.updateListRow(send)
		},
		updateListRow(send) {
			index.getPublicUserMember(send,'client/individual/update/notification','post',res=>{
				if(res.data.code == 200 && res.data.success){
					setTimeout(()=>{
						this.getListRow()
					},500)
				}else{
					index.show_tips(res.data.message)
					return false
				}
			})
		}
	},
	onLoad() {
		this.getListRow()
	}
}		
</script>

<style>
@import url("@/static/css/publics.css");
@import url("@/static/css/systemSet.css");		
</style>